import {Injectable} from "@angular/core";
import { HttpClient,HttpParams } from '@angular/common/http';
import {toPromise} from "rxjs-compat/operator/toPromise";

@Injectable()
export class CodeService {
  serveUrl='https://codeserver.lessonplan.cn'; /*进入码地址*/
  constructor(
    private http: HttpClient,
  ) { }
/*用户根据邀请码进行查询应用进入地址*/
  searchAppUrl(code:string):Promise<any>{
    return this.http.get(this.serveUrl+'/api/search',{
      params:new HttpParams().set('text',code)
    }).toPromise().then(res=>{
      return res;
    })
  }
/*获去所有应用的名称*/
  getAppNameList():Promise<any>{
    return this.http.get(this.serveUrl+'/api/project').toPromise().then(res=>{
      return res;
    })
  }
  /*根据班级guid查询这个班级的推送*/
  getClassPushs(classGuid:string):Promise<any>{
    return this.http.get(this.serveUrl+'/api/class/'+classGuid).toPromise().then(res=>{
      return res;
    })
  }
  /*根据班级guid获取每天的推送*/
  getClassPushsByDay(classGuid:string):Promise<any>{
    return this.http.get(this.serveUrl+'/api/classByDay/'+classGuid).toPromise().then(res=>{
      return res
    })
  }
}



